package com.ryskoo.catering.productattrvalue.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.productattrvalue.domain.ProductAttrValuePO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class ProductAttrValueRedisImpl extends BasicRedisImpl<ProductAttrValuePO> implements IProductAttrValueRepository{

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IProductAttrValueRepository productAttrValueRepository;
    @PostConstruct
    public void init(){
        this.setDao(productAttrValueRepository);
        this.setRedisClient(redisClient);
    }

    public ProductAttrValueRedisImpl() {
        super(HCLCacheConstant.HCL_PRODUCTATTRVALUE_KEY);
    }

    @Override
    public void deleteByAttrIds(List<String> attrIds) {
        productAttrValueRepository.deleteByAttrIds(attrIds);
    }

    @Override
    public List<ProductAttrValuePO> getValuesByAttrId(String attrId) {
        return productAttrValueRepository.getValuesByAttrId(attrId);
    }

}
